import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'home',
    // 推荐使用函数形式进行懒加载
    component: () => import('../view/Home.vue')
  },
  {
   path: '/login',
   name: 'login',
   component: () => import('../view/admin/Login.vue') 
  },{
    path: '/admin',
    name: 'admin',
    component: () => import('../view/admin/Admin.vue'),
    redirect: '/admin/home',
    children: [
      {
        path: 'home',
        name: 'Home',
        component: () => import('../view/admin/Home.vue')
      }, 
      {
       path:'about',
       name: 'About',
       component: () => import('../view/admin/About.vue') 
      },
      {
        path: 'data',
        name: 'Data',
        component: () => import('../view/admin/Data.vue')
      }
    ]
  }
]

const router = createRouter({
  // 使用 history 模式。如果服务器不支持，请使用 createWebHashHistory()
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router